<template>
  <el-scrollbar class="scrollBox" style="height: 500px">
    <div v-for="(n, i) in props.selectList" :key="i" class="selectList">
      <el-tag type="info" closable @close="handleClose(n)">
        <slot name="selectName" :item="n"></slot>
      </el-tag>
    </div>
  </el-scrollbar>
</template>

<script lang="ts" setup>
const props = defineProps({
  selectList: {
    type: Object,
  },
  filterList: {
    type: Function,
  },
  iSarea: {
    type: Boolean,
  },
  keyId: {
    type: String,
  },
})
const emit = defineEmits(['update:selectList'])
const handleClose = (e) => {
  const key = props.keyId
  let list = props.selectList.filter((x) => x[key] !== e[key])
  emit('update:selectList', list)
  props.filterList(key)
}
</script>

<style lang="scss" scoped>
.selectList {
  padding: 4px;
}
</style>
